package com.lb.shopguide.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lb.shopguide.R;


/**
 * author：zhangxy
 * time：2016/12/1  14:18.
 * descr：
 */

public class NormalEdittextTitleBar extends RelativeLayout {
    private RelativeLayout layoutSearch;
    private TextView tvSearch;
    private ImageButton ivLeft;
    private RelativeLayout layoutRoot;

    private Context context;

    public NormalEdittextTitleBar(Context context) {
        super(context, null);
        this.context = context;
    }

    public NormalEdittextTitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        View view = LayoutInflater.from(context).inflate(R.layout.bar_normal_edittext, this);
        ivLeft = view.findViewById(R.id.image_left);
        layoutSearch = view.findViewById(R.id.layout_search);
        layoutRoot = view.findViewById(R.id.common_title);
    }


    /**
     * 左图标
     *
     * @param id
     */
    public void setLeftImageSrc(int id) {
        ivLeft.setVisibility(View.VISIBLE);
        ivLeft.setImageResource(id);
    }


    public void setBackground(int color) {
        layoutRoot.setBackgroundColor(color);
    }

    /*
     * 点击事件
     */
    public void setOnLeftImageListener(OnClickListener listener) {
        ivLeft.setOnClickListener(listener);
    }

    public void setOnTitleClickListener(OnClickListener listener) {
        layoutSearch.setOnClickListener(listener);
    }

}
